#ifndef COMMSERIALSINGLE_H
#define COMMSERIALSINGLE_H

#include <memory>

class QString;
class QSerialPort;
class QSerialPortInfo;

class CommSerialSingle
{
public:
    CommSerialSingle(const CommSerialSingle& rhs) = delete;
    CommSerialSingle& operator=(const CommSerialSingle& rhs) = delete;

public:
    static std::shared_ptr<CommSerialSingle> GetInstance();
    static void Destory(CommSerialSingle* s);

    void OpenPort(QString& name);  //new m_PortInfo
    void ClosePort();             //delete m_PortInfo

    QSerialPort* GetPort();

private:
    CommSerialSingle();
    ~CommSerialSingle();

private:
    static std::shared_ptr<CommSerialSingle> _S;

private:
    QSerialPort* m_Port;
    QSerialPortInfo* m_PortInfo;
};

#endif // COMMSERIALSINGLE_H
